package cn.zc.student.service.controller;



import cn.tools.core.base.R;
import cn.zc.student.entity.Dto.StudentUserDto;
import cn.zc.student.entity.VO.StudentUserVO;
import cn.zc.student.service.service.StudentUserService;
import cn.zc.tools.security.utils.SecurityUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 * 学生用户表 前端控制器
 * </p>
 *
 * @author keno
 * @since 2022-02-23
 */
@Api(tags = "学生用户登录接口")
@RestController
@RequestMapping("/student")
public class StudentUserController {

    @Resource
    private StudentUserService studentUserService;

    @Resource
    private SecurityUtils securityUtils;

    /**
     * 注册学生用户
     * @param studentUserDto
     * @return
     */
    @ApiOperation(value = "注册学生用户")
    @PostMapping("/create/StudentUser")
    private R createStudentUser(@RequestBody StudentUserDto studentUserDto){
        studentUserService.createStudentUser(studentUserDto);
        return R.success();
    }


    @ApiOperation(value = "登录用户")
    @PostMapping("/studentPasswordLogin")
    private StudentUserVO studentPasswordLogin(String userName, String passWord){
        StudentUserVO studentUserVO = studentUserService.studentPasswordLogin(userName,passWord);
        return studentUserVO;
    }


//    @GetMapping("/test")
//    private void test(){
//        System.out.println(securityUtils.getSecurityUser().getUsername());
//    }
}

